#include "arena.h"
#include "bullet.h"
#include <QPushButton>
#include <QHBoxLayout>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QTimer>
#include <iostream>

Arena::Arena(int width, int height, QWidget *parent) :
    QScrollArea(parent)
{
    QGraphicsScene* scene = new QGraphicsScene();
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    QGraphicsView* view = new QGraphicsView();
    view->setMinimumSize(width, height);
    view->setScene(scene);
    view->setAlignment(Qt::AlignBottom | Qt::AlignLeft);
    view->setCacheMode(QGraphicsView::CacheBackground);
    view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    view->setDragMode(QGraphicsView::ScrollHandDrag);
    view->setRenderHint(QPainter::Antialiasing);

    this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setWidget(view);

    Bullet* b = new Bullet();
    scene->addItem(b);

    QTimer* timer = new QTimer;
    connect(timer, SIGNAL(timeout()), scene, SLOT(advance()));
    timer->start(1000 / 33);
}
